package org.eiahe.hr.attendance.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.ehe.common.core.BaseController;
import org.ehe.common.core.domain.R;
import org.ehe.common.mybatis.core.page.PageQuery;
import org.ehe.common.mybatis.core.page.TableDataInfo;
import org.eiahe.hr.attendance.domain.bo.SpecialRuleApprovalLogBo;
import org.eiahe.hr.attendance.domain.vo.SpecialRuleApprovalLogVo;
import org.eiahe.hr.attendance.service.ISpecialRuleApprovalLogService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 特殊规则审批日志管理控制器
 *
 * @author zhangnn
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/attendance/specialRuleLog")
public class SpecialRuleApprovalLogController extends BaseController {

    private final ISpecialRuleApprovalLogService specialRuleApprovalLogService;

    /**
     * 查询特殊规则审批日志列表
     */
    @SaCheckPermission("attendance:specialRule:list")
    @GetMapping("/list")
    public TableDataInfo<SpecialRuleApprovalLogVo> list(SpecialRuleApprovalLogBo bo, PageQuery pageQuery) {
        return specialRuleApprovalLogService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取特殊规则审批日志详细信息
     */
    @SaCheckPermission("attendance:specialRule:query")
    @GetMapping("/{logId}")
    public R<SpecialRuleApprovalLogVo> getInfo(@PathVariable Long logId) {
        return R.ok(specialRuleApprovalLogService.queryById(logId));
    }

    /**
     * 根据规则ID查询审批日志
     */
    @SaCheckPermission("attendance:specialRule:query")
    @GetMapping("/rule/{ruleId}")
    public R<List<SpecialRuleApprovalLogVo>> getByRuleId(@PathVariable Long ruleId) {
        return R.ok(specialRuleApprovalLogService.queryByRuleId(ruleId));
    }
}
